<template>
    <div>

        <el-table :data="diseaseData" style="width: 100%">
            <el-table-column label="Date" prop="date" />
            <el-table-column label="Name" prop="name" />
            <el-table-column align="right">
            <template #header>
                <el-button size="small" @click="handleEdit(scope.$index, scope.row)">
                   增加
                </el-button>
            </template>
            <template #default="scope">
                <el-button
                    size="small"
                    type="danger"
                    @click="handleDelete(scope.$index, scope.row)"
                >
                    删除
                </el-button>
            </template>
            </el-table-column>
        </el-table>

        <el-form :model="form" label-width="auto" style="max-width: 600px">

            <el-form-item label="注意事项">
                <el-input v-model="form.careful" />
            </el-form-item>
            <el-form-item label="断诊结果">
                <el-input v-model="form.diagnosis" />
            </el-form-item>
            <el-form-item label="理处意见">
                <el-input v-model="form.cure" />
            </el-form-item>
            <el-form-item>
                <el-button @click="saveRecord">保存</el-button><el-button>重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script setup>
import httpRequest from '@/common';
import { ElMessage } from 'element-plus';
import {ref,getCurrentInstance, onMounted,defineProps, watch} from 'vue';

const {proxy} = getCurrentInstance();

//获取父组件传递的registerId  挂号id
const props = defineProps({
    rid:{
        type: Number,
        required: true
    }
});

const form = ref({

})

//  进入该页面说明病例已经创建出来了   先查询该病例
//进入组件就进行查询
const getRecordById = ()=>{

    httpRequest(
        proxy,
        'get',
        '/medicalrecord/register/'+props.rid,
        null,
        resultBean=>{
            form.value = resultBean.data;
        }
    )

}

const diseaseData = ref([])

const getDiseaseList = ()=>{
    
}

onMounted(()=>{
    // 在onMounted中直接获取props中父组件的传值会获取不到  设置一个定时任务
    setTimeout(()=>{
        getRecordById();
    },200);
})
</script>

<style>
</style>